package com.easy.easylibdemo.ui.greendao.model;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.ToMany;

import java.util.List;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.DaoException;
import com.easy.easylibdemo.gen.DaoSession;
import com.easy.easylibdemo.gen.TwoBeanDao;
import com.easy.easylibdemo.gen.OneBeanDao;

/**
 * 作　　者: guyj
 * 修改日期: 2017/2/17
 * 描　　述:
 * 备　　注:
 */
@Entity
public class OneBean {
    @Id(autoincrement = true)
    private Long id;
    @ToMany(referencedJoinProperty = "TwoBeanId")
    private List<TwoBean> beanList;
    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;
    /** Used for active entity operations. */
    @Generated(hash = 1758177000)
    private transient OneBeanDao myDao;
    @Generated(hash = 900358883)
    public OneBean(Long id) {
        this.id = id;
    }
    @Generated(hash = 1133505385)
    public OneBean() {
    }
    public Long getId() {
        return this.id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    /**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Generated(hash = 598865132)
    public List<TwoBean> getBeanList() {
        if (beanList == null) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            TwoBeanDao targetDao = daoSession.getTwoBeanDao();
            List<TwoBean> beanListNew = targetDao._queryOneBean_BeanList(id);
            synchronized (this) {
                if (beanList == null) {
                    beanList = beanListNew;
                }
            }
        }
        return beanList;
    }
    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
    @Generated(hash = 1732379025)
    public synchronized void resetBeanList() {
        beanList = null;
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 233211642)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getOneBeanDao() : null;
    }

}
